package org.cerberus.platform.system;

import org.cerberus.platform.api.IPlatform;
import org.cerberus.platform.api.OnActivate;
import org.cerberus.platform.api.OnDeactivate;
import org.cerberus.platform.api.PComponent;
import org.cerberus.platform.api.PInject;
import org.cerberus.platform.api.PModule;
import org.cerberus.platform.api.PStatic;
import org.cerberus.platform.components.PFileSystem;

@PModule(id="SystemPlugin", 
		priority=Integer.MAX_VALUE, 
		autostart=true)
@PComponent(classID="System")
public class SystemModule {

	public static final String SYSTEM_PLUGIN = "SystemPlugin";
	
	@PInject
	private IPlatform platform;
	private PFileSystem fileSystem;
	
	@OnActivate
	public void start() {
		fileSystem = new PFileSystem();
		platform.addRoot(this);
		platform.publishComponent(this, SYSTEM_PLUGIN);
	}
	
	@OnDeactivate
	public void stop() {
		platform.unpublishComponent(SYSTEM_PLUGIN);
		platform.removeRoot(this);
	}
	
	public PFileSystem getFileSystem() {
		return fileSystem;
	}
	
	public static SystemModule getInstance() {
		return (SystemModule)PStatic.getPlatform().getPublishedComponent(SYSTEM_PLUGIN);
	}
	
	
}
